package com.egreen.admin.excptions;


import com.egreen.admin.common.JwtExceptions;
import com.egreen.common.Result;
import com.egreen.common.States;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author cloudJiang
 * @date 2022/6/24 9:14
 */
@ControllerAdvice
public class CommonExceptionHandler {

   /* @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result unknownException(Exception e) {
        return new Result(null, States.ERR_UNKNOWN.getStates(), States.ERR_UNKNOWN.getDescription());
    }*/

    /**
     * 处理jwt异常
     *
     * @param ex
     * @return
     */
    @ExceptionHandler({JwtExceptions.class})
    @ResponseBody
    public Result jwtError(JwtExceptions ex) {
        return Result.Error(ex.getStates());
    }

}
